/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.form;

import org.rails.extjs.AbsBase;
import org.rails.extjs.Parameters;
import org.rails.extjs.javascript.Function;

public abstract class ActionBase extends AbsBase {
	
	private Parameters params = new Parameters();

	public ActionBase() {
		super();
		addOption("params",params);
	}
	
	public void setFailure(Function failure){
		addOption("failure", failure);
	}
	
	public Function getFailure(){
		return (Function)getOption("failure");
	}

	public void setMethod(String method){
		addOption("method", method);
	}
	
	public String getMethod(){
		return getString("method","GET");
	}
	
	public void addParam(String name,Object value){
		params.put(name, value);
	}
	
	public void removeParam(String name){
		params.remove(name);
	}
	
	public void clearParams(){
		params.clear();
	}
	
	public Object getParam(String name){
		return params.get(name);
	}
	
	public Parameters getParams(){
		return params;
	}
	
	public void setReset(Boolean reset){
		addOption("reset", reset);
	}
	
	public Boolean isReset(){
		return getBoolean("reset",true);
	}
	
	public void setSuccess(Function success){
		addOption("success", success);
	}
	
	public Function getSuccess(){
		return (Function)getOption("success");
	}
	
	public void setTimeout(Integer timeout) {
		addOption("timeout", timeout);
	}

	public Integer getTimeout() {
		return getInteger("timeout", 30000);
	}
	
	public String getUrl() {
		return getString("url", "");
	}

	public void setUrl(String url) {
		addOption("url", url);
	}
	
	public void setWait(String title,String msg){
		addOption("waitMsg",msg);
		addOption("waitTitle",title);
	}
	
		

}
